package com.manbu.live.id.generate.provider.dto.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.manbu.live.id.generate.provider.dto.po.IdGeneratePO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * @author hanWang
 * @Title:
 * @Package
 * @Description:
 * @date 2024/1/2412:30 PM
 */
@Mapper
public interface IdGenerateMapper extends BaseMapper<IdGeneratePO> {

    //    @Update("update t_id_generate_config set next_threshold = next_threshold + step,current_start=current_start + step , version = version + 1 where id = #{id} and version = #{version}")
//    int updateNewIdCountAndVersion(@Param("id") int id, @Param("version") int version);
    @Update("update t_id_generate_config set next_threshold=next_threshold+step," +
            "current_start=current_start+step,version=version+1 where id =#{id} and version=#{version}")
    int updateNewIdCountAndVersion(@Param("id") int id, @Param("version") int version);

    @Select("select * from t_id_generate_config")
    List<IdGeneratePO> selectAll();
}
